

package com.kingdee.eas.fi.ar.client;

import java.awt.event.ActionEvent;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.swing.KDDatePicker;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.basedata.org.*;
import com.kingdee.eas.basedata.scm.sd.sale.PriceParamInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.scm.common.client.SCMGroupClientUtils;
import com.kingdee.util.UuidException;


public class OtherBillEditUICTEx extends OtherBillEditUI
{

    public OtherBillEditUICTEx()
        throws Exception   
    {
        priceParamControlHelper = null;
        priceParamInfo = null;
    }

    protected void afterMainOrgChanged(String s, String s1)
    {
        String saleOrgUnitID = s1;
        super.afterMainOrgChanged(s, s1);
        if(s1 != null)
        {
            try
            {
                OrgUnitCollection orgs = SCMGroupClientUtils.getOrgsByRelation(getMainBizOrgType(), OrgType.Sale, BOSUuid.read(s1));
                if(orgs.size() > 0)
                    saleOrgUnitID = orgs.get(0).getId().toString();
            }
            catch(EASBizException e)
            {
                e.printStackTrace();
            }
            catch(BOSException e)
            {
                e.printStackTrace();
            }
            catch(UuidException e)
            {
                e.printStackTrace();
            }
            initPriceControlHelper(saleOrgUnitID);
        }
    }

    public void setPlanDate(KDBizPromptBox prmtAccountCussent, KDBizPromptBox prmtOrgUnit, KDDatePicker datePicker)
        throws EASBizException, BOSException
    {
        super.setPlanDate(prmtAccountCussent, prmtOrgUnit, datePicker);
        if(prmtOrgUnit == prmtSaleOrgUnit && prmtSaleOrgUnit.getValue() != null)
        {
            String saleOrgUnitID = ((OrgUnitInfo)prmtSaleOrgUnit.getValue()).getId().toString();
            initPriceControlHelper(saleOrgUnitID);
        }
    }

    private void initPriceControlHelper(String saleOrgUnitID)
    {
        if(EDITCTRLTAB != null)
        {
            if(priceParamControlHelper != null)
                priceParamControlHelper.unRegisterCtrlTableCol(kdtEntry, EDITCTRLTAB);
            priceParamControlHelper = new ArPriceParamControlHelper(this, saleOrgUnitID, priceParamInfo);
            priceParamControlHelper.registerCtrlTableCol(kdtEntry, EDITCTRLTAB);
            priceParamControlHelper.initUI();
        }
    }   

    String EDITCTRLTAB[] = {
        "price", "amount", "taxPrice", "taxAmount"
    };
    ArPriceParamControlHelper priceParamControlHelper;
    PriceParamInfo priceParamInfo;
    
   
    public SelectorItemCollection getSelectors() {
    	// TODO Auto-generated method stub
    	SelectorItemCollection sic= super.getSelectors();
    	
    	sic.add(new SelectorItemInfo("saleWay.name"));    
    	sic.add(new SelectorItemInfo("wgisAddTax"));
    	return sic;
    }  
}


